package com.tedu.springdemo.day04;



import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * 注解   针对于  Spring  DI依赖注入
 * @Value  用于属性，给属性直接注入值
 */

@Component
public class Demo {
    @Value("${name}")   //替代：<property name="name" value=""项羽凡>
    private String name;
    @Value("${age}")
    private int age;
    @Value("#{@list1}")
    private List<String> list;
    @Value("#{@set1}")
    private Set<String> set;
    @Value("#{@map1}")
    private Map<String, Object> map;
    @Value("#{@properties1}")
    private Properties properties;//静态文件类型【类】
    //引用类型   DI注入 @Autowired自动装配
    @Autowired
    //@Qualifier("p")//按照Id的方式找对象
    private pig p;


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public List<String> getList() {
        return list;
    }

    public void setList(List<String> list) {
        this.list = list;
    }

    public Set<String> getSet() {
        return set;
    }

    public void setSet(Set<String> set) {
        this.set = set;
    }

    public Map<String, Object> getMap() {
        return map;
    }

    public void setMap(Map<String, Object> map) {
        this.map = map;
    }

    public Properties getProperties() {
        return properties;
    }

    public void setProperties(Properties properties) {
        this.properties = properties;
    }
    //打印  属性的值  toString()  包.类@16进制值【不需要手写】


    public pig getP() {
        return p;
    }

    public void setP(pig p) {
        this.p = p;
    }
}

